<template>
  <div class="collect">
    <van-nav-bar
      title="我的收藏"
      left-text="返回"
      left-arrow
      @click-left="goback"
    />
    <div class="collectbox">
      <div
        class="box"
        v-for="item in collectGoodsList"
        :key="item.id"
        @click="goGoodsdetail(item.id)"
      >
        <img :src="item.list_pic_url" alt="" />
        <p class="name">{{ item.name }}</p>
        <p class="price">¥{{ item.retail_price }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import { listAction } from "@/api/user/collect/index";
export default {
  name: "WorkspaceJsonIndex",

  data() {
    return {
      collectGoodsList: [],
    };
  },

  created() {
    listAction({
      openId: localStorage.getItem("openId"),
    }).then((res) => {
      console.log(res);
      this.collectGoodsList = res.collectGoodsList;
    });
  },

  mounted() {},

  methods: {
    goback() {
      this.$router.go(-1);
    },
    goGoodsdetail(val) {
      this.$router.push({
        name: "categoryGoodsdetail",
        query: {
          id: val,
        },
      });
    },
  },
};
</script>

<style scoped lang="scss">
@import "../scss/collect/index.scss";
* {
  margin: 0;
  padding: 0;
}
</style>